<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>转让管理员权限</title>
    <link rel="stylesheet" href="/asset/layui/css/layui.css">
    <link rel="stylesheet" href="/asset/css/base.css">
    <link rel="stylesheet" href="/asset/css/index.css">
    
    <link rel="Shortcut Icon" href="cachet.ico">
    <script type="text/javascript" src="/asset/js/jquery-3.3.1.min.js"></script>
	<script src="/asset/layui/layui.js"></script>
    <script src="/asset/js/common.js"></script>
</head>
<body >
<div class="x-body">

	<form class="layui-form">
          
          <div class="layui-form-item">
          	  <label for="model" class="layui-form-label">新保管员</label>
              <div class="layui-input-inline" >
                  <input type="text" id="keyword" name="keyword"  placeholder="请输入姓名或账户搜索"  autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid">
              <a href="javascript:void(0);" id="search"><i class="layui-icon layui-icon-search" style="font-size: 25px;"></i></a>
              </div>
          </div>
          
          <div class="layui-form-item layui-hide" id="user">
          	  <label for="model" class="layui-form-label"></label>
              <div class="layui-input-inline" id="userinfo">
          			<div class="user">
          				<input type="hidden" name="partyId" value="3">
          				<div class="avatar"><img src="http://gzws.oss-cn-hangzhou.aliyuncs.com/upload/portrait/20180926/153797405467043929f57.png"></div>
          				<div class="info">
          					<div class="name">小新</div>
          					<div class="position">运营总监</div>
          				</div>
          			</div>
              </div>
          </div>
          
          <div class="layui-form-item">
          	  <label for="model" class="layui-form-label">手机号码</label>
              <div class="layui-input-inline layui-form-mid layui-word-aux">
                  ${party.userLoginId?substring(0,3)}****${ party.userLoginId?substring(7)}
              </div>
          </div>
          
          <div class="layui-form-item">
          	  <label for="model" class="layui-form-label">短信验证码</label>
              <div class="layui-input-inline" style="width:115px">
                  <input type="text" id="smsCode" name="smsCode"   autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-postfix"><button id="sendsms" class="layui-btn layui-btn-primary">获取</button></div>
          </div>
          
          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
              </label>
              <button  class="layui-btn" lay-filter="add" lay-submit="">提交</button>
          </div>
      </form>
</div>

    <script>
    		
    
        layui.use(['form','layer','laydate'], function(){
            $ = layui.jquery;
          var form = layui.form,layer = layui.layer,laydate = layui.laydate;
        
        
          $("#search").click(function(){
          	  var keyword = $("#keyword").val();
	          if(!keyword){
	          	 layer.msg('请输入姓名或登陆账户搜索');
	          	 return false;
	          }
	          
	          $.ajax({
	      			type:"GET", 
	      			url:"/staff/search.htm",
	      			data:{searchKey:keyword},
	      			success:function(result) {
	      				console.log(result);
			      		if(result.code=='1'){
			      			var data = result.data;
			      			if(data.partyId){
				      			var tr = $(['<div class="user">'
									          ,'<input type="hidden" name="toPartyId" value="'+data.partyId+'">'
									          ,'<div class="avatar"><img src="'+data.portrait+'"></div>'
										          ,'<div class="info">'
										          	,'<div class="name">'+data.name+'</div>'
										          	,'<div class="position">'+data.position+'</div>'
										          ,'</div>'
									          ,'</td>'
									        ,'</td>'].join(''));
				      			
			          			 $("#userinfo").html(tr);	
		          			 }else{
		          			 	$("#userinfo").html('<span class="color_red">未查询到此用户</span>');	
		          			 }
		          			 $("#user").removeClass("layui-hide");		
		          					
		          				
			      			
			      		}else{
			      		 	layer.msg(result.msg);
			      		}
			    	 } 
			   }); 
	          
          })
          
          $("#sendsms").click(function(){
          		
          		if(regist.countdown !=60){
          			return false;
          		}
          		regist.sendButt = $(this);
          		
          		$.ajax({
	      			type:"POST", 
	      			url:"/sms/send.htm",
	      			data:{mobile:'${party.userLoginId}'},
	      			success:function(result) {
			      		if(result.code=='1'){
          					regist.startTime();
			      			layer.msg("验证码发送成功，请注意查收");
			      		}else{
			      		 	layer.msg(result.msg);
			      		}
			      
			    	 } 
			    }); 
			    
			    return false;
          
          })

          //监听提交
          form.on('submit(add)', function(data){
            $.ajax({
      			type:"POST", 
      			url:"/company/transfer/submit.htm",
      			data:data.field,
      			success:function(result) {
		      
		      		if(result.code=='1'){
		      			layer.alert("设置成功", {icon: 6},function () {
			                // 获得frame索引
			                 window.parent.location.reload();
			                var index = parent.layer.getFrameIndex(window.name);
			                //关闭当前frame
			                parent.layer.close(index);
			            });
		      		}else{
		      		 	layer.msg(result.msg);
		      		}
		      
		    	 } 
		    }); 
            
            return false;
          });
          
        });
        
        
        var regist={
			countdown: 60,
			startTime: function() {
				if (regist.countdown <= 0) {
					regist.sendButt.removeClass("layui-btn-disabled");
					regist.sendButt.text("重新发送");
					regist.countdown = 60;
				} else {
					regist.sendButt.addClass("layui-btn-disabled");
					regist.sendButt.text(regist.countdown + "秒");
					regist.countdown--;
					setTimeout(function() {
						regist.startTime()
					}, 1000)
				}
			}
		}

        
        
        
    </script>

</body>
</html>